/*
10. Write a program to calculate the sum (with accuracy of 0.001): 1 + 1/2 - 1/3 + 1/4 - 1/5 + ...
*/
using System;

class sunOfInvertedN
{
    static void Main()
    {
        float newSum = 1f;
        float oldSum = 0f;
        int positionInSequence = 2;
        while (true)
        {
            if (Math.Abs(oldSum - newSum) < 0.001f) break;
            else
            {
                oldSum = newSum;
                if (positionInSequence % 2 == 0) newSum = oldSum + 1 / ((float)positionInSequence);
                else newSum = oldSum - 1 / ((float)positionInSequence);
                positionInSequence++;
            }
        }
        Console.WriteLine(oldSum);
    }
}